home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gigarom 1
/
Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso
/
FILES
/
BBS
/
MUBBS
/
MUBBS etc.cpt
/
Module Source
/
Caller Module code
/
Caller Module.c
next >
Wrap
Text File
|
1991-11-14
|
3KB
|
98 lines
/*
* Caller Module.c
*
* This program source code and it's compiled version is
* Copyright (c) 1991 N. Hawthorn.
* This program source code and it's compiled version IS NOT IN THE
* PUBLIC DOMAIN ! Please read the "COPYRIGHT NOTICE / NH" file for details
* regarding use of this program source code and it's compiled version.
*
* This module's name is "maincaller", it's type is "MOD1", it's ID is 128
* because we know the menu module's ID is 131. Normally a resource mover
* would assign a new number to it, that's why we name our modules !
*
* This is where it all starts...
*
*/
#define INMAIN
#include <SetUpA4.h>
#include "MUBBS Module.h"
/* my globals for this module */
pascal void main (mode1,G1,P1)
int mode1;
struct GS *G1;
Ptr *P1; /* we ignore "P" in this module */
{
Handle temph;
float version = 0.5; /* what version of MUBBS you are compatable with IE: .5 and above */
RememberA0(); SetUpA4(); /* This sets up the A4 register to access our globals */
asm { _RecoverHandle }; asm {move.l a0,temph}; HLock(temph); /* locks our module, do this ! */
G=G1; /* This MUST be the first thing you do in main only, it sets up the struct globals */
mode[u]=mode1; /* set up our mode so that you can read it anywhere */
switch (mode[u]) { /* any un-handled modes return error from this module */
case 2:
callthem();
G->moduleresult=0;
break;
case 98:
versionck(version); /* just return after this call, don't modify anything */
break;
case 0:
strcpy (G->programmer,"N Hawthorn"); /* show the programmer's name up to 20 chars*/
G->moduleresult=0; /* this was also a init call if we need close call put 99 here */
break;
default:
G->moduleresult=1; /* return bad code */
};
HUnlock(temph); /* unlocks this module, do this ! */
RestoreA4(); /* call this when you are all done */
}
callthem() /* call a list of modules in order */
{
FILE *stream;
char tocall[21][28]; /* takes up about 1K of stack space, module names not over 26 chars */
char filename[64];
int i,x;
if (!G->online[u]) return; /* do this check so we can log out if hang up */
/* Generate the filename */
strcpy(filename,":caller:");
strcat(filename,G->modulename[u]);
strcat(filename,".info");
if ((stream = fopen(filename, "r")) == NULL) { /* Open the file */
send("]FILE ERROR cannot open %s ]", filename);
return;
}
else /* If no error, read from the file */
{
i = 0;
while (i < 20){
if (fscanf(stream,"%27[^\n]\n",tocall[i]) == EOF) break; /* end on EOF */
i++;
}
fclose(stream); /* always close the file even if empty */
}
if (i==0) return; /* exit if file empty */
for (x = 0; x<i; x++) /* Launch the modules */
{
module(2,tocall[x],0L);
if (!G->online[u]) return; /* do this check so we can log out if hang up */
}
}